<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Huopin extends Model
{
    protected $guarded=[];

    protected $casts=[
        'attrs'=>'array'
    ];
    /**
     * @param $goodsCategory
     * @return string
     */
    public function getAttr($huopinAttrs){
//        dd($goodsCategory);
        $newArr=[];
        foreach ($huopinAttrs as $value){
            $newArr[]=Attr::where('id',$value)->value('attr_name');
        }
        // 将获得的分类数组数据转换为json数据
        return json_encode($newArr,JSON_UNESCAPED_UNICODE);
    }
}
